/**
 * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.jtalk.ui.command;

import it.uniba.di.cdg.jtalk.IApplicationFacade;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.osgi.service.log.LogService;

import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
 * Log-off from actual connection.
 */
@Singleton
public class LogOffCommand extends AbstractHandler {
	
	private final IApplicationFacade applicationFacade;
	private final LogService logger;

	@Inject
	public LogOffCommand( IApplicationFacade applicationFacade, LogService logger ) {
		this.applicationFacade = applicationFacade;
		this.logger = logger;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.internal.handlers.QuitHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
	@Override
	public Object execute( ExecutionEvent event ) throws ExecutionException {
		logger.log( LogService.LOG_DEBUG, "Loggin' out Command" );
		
		applicationFacade.logOff();
		
		return null;
	}
}
